import {
    DataViewActionType,
    IDataViewAbility,
    IDataViewController,
    IDataViewControllerParams,
    IDataViewModel,
    IDataViewStore,
    IParam,
    IViewEvent,
} from '@/core';
import { QXEvent } from 'qx-util';
import {
    getViewClassNames,
    handleQuickGroupValueChange,
    useViewAction,
    useViewBasic,
    useViewControllerParams,
    useViewProps,
} from '../use-view';

/**
 * 获取图表视图输入参数
 *
 * @export
 * @return {*}
 */
export function useDataViewProps() {
    return {
        ...useViewProps(),
    };
}

/**
 * 获取图表视图基础
 *
 * @export
 * @param {IDataViewModel} model 图表视图模型
 * @param {IParam} props 输入参数
 * @return {*}
 */
export function useDataViewBasic(model: IDataViewModel, props: IParam) {
    const getSearchFormSlotName = (props: IParam) => {
        const showTabPageExp = App.getProjectSetting().multiTabsSetting.show;
        let searchFormSlotName = 'viewHeaderTop';
        if (!showTabPageExp && props.openType == 'ROUTE') {
            searchFormSlotName = 'viewHeaderBottom';
        }
        return searchFormSlotName;
    }
    const getClassNames = (props: IParam) => {
        return getViewClassNames(model, props)
    }
    return {
        ...useViewBasic(model, props),
        getClassNames,
        getSearchFormSlotName,
        handleQuickGroupValueChange,
    };
}

/**
 * 图表视图行为
 *
 * @export
 */
export function useDataViewAction(controller: IDataViewController<IDataViewStore, IDataViewAbility>) {
    return {
        ...useViewAction(controller)
    };
}

/**
 * 获取图表视图控制器输入参数
 *
 * @export
 * @param {IDataViewModel} model
 * @param {IParam} props
 * @param {QXEvent<IViewEvent<DataViewActionType, IDataViewAbility>>} evt
 * @return {*}  {IDataViewControllerParams<DataViewActionType, IDataViewAbility>}
 */
export function useDataViewControllerParams(
    model: IDataViewModel,
    props: IParam,
    evt: QXEvent<IViewEvent<DataViewActionType, IDataViewAbility>>
): IDataViewControllerParams<DataViewActionType, IDataViewAbility> {
    return {
        ...useViewControllerParams<IDataViewStore, IDataViewModel>(
            model,
            props,
            evt
        ),
    };
}
